package cn.mesmile.swagger.service.impl;
import java.util.ArrayList;
import java.util.Date;

import cn.hutool.core.date.DateUtil;
import cn.mesmile.swagger.dto.EmployeeDTO;
import cn.mesmile.swagger.entity.Employee;
import cn.mesmile.swagger.service.SwaggerService;
import cn.mesmile.swagger.vo.EmployeeVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zb
 * @date 2021/4/19 11:43
 * @Description
 */
@Slf4j
@Service
public class SwaggerServiceImpl implements SwaggerService {


    @Override
    public List<EmployeeVO> queryEmployeeList(EmployeeDTO employeeDTO) {
        System.out.println("-----------------------------------------");
        System.out.println(">>>>>>>>>> employeeDTO = " + employeeDTO);
        System.out.println("DateUtil.formatDate(employeeDTO.getBirthday()) = " + DateUtil.formatDate(employeeDTO.getBirthday()));
        System.out.println("DateUtil.formatDate(employeeDTO.getBirthday()) = " + DateUtil.formatDateTime(employeeDTO.getBirthday()));
        System.out.println("DateUtil.formatDateTime(employeeDTO.getCreateDateTime()) = " + DateUtil.formatDateTime(employeeDTO.getCreateDateTime()));
        System.out.println("-----------------------------------------");
        List<EmployeeVO> employeeVOList = new ArrayList<>(3);
        for (int i = 0; i < 3; i++) {
            Employee employee = new Employee();
            employee.setUsername("用户 "+ i);
            employee.setPassword("密码 "+ i);
            employee.setRelease(false);
            employee.setAge(i+20);
            employee.setCreateDateTime(employeeDTO.getCreateDateTime());
            employee.setModifiedDateTime(DateUtil.offsetHour(new Date(),i));
            employee.setBirthday(DateUtil.offsetDay(new Date(),i));
            EmployeeVO employeeVO = new EmployeeVO();
            BeanUtils.copyProperties(employee, employeeVO);
            employeeVOList.add(employeeVO);
        }
        return employeeVOList;
    }
}
